#include <bits/stdc++.h>

using namespace std;

const int mod = 1e9+7;

typedef long long ll;

ll f[22][12],s[22][12];
int d[22],cnt = 0;

void predo(){
	for(int i = 0;i <= 9;i++) f[1][i] = 1,s[1][i] = i;
	for(int i = 2;i <= 18;i++)
		for(int j = 0;j <= 9;j++)
			for(int k = 0;k <= 9;k++){
				(s[i][j] += (s[i-1][k] + f[i-1][k] * j %mod))%=mod;
				(f[i][j] += f[i-1][k])%=mod;
			}
}

void divide(ll x){
	cnt = 0;
	while(x > 0){
		d[++cnt] = x%10;
		x /= 10;
	}
}

ll sum(ll x){
	divide(x); ll res = 0;
	for(int i = 1;i < cnt;i++)
		for(int j = 1;j <= 9;j++)
			(res += s[i][j])%=mod;
	int lim = d[cnt];
	for(int i = 1;i < lim;i++) res = (res + s[cnt][i]) % mod;
	ll tot = d[cnt];
	for(int i = cnt-1;i >= 1;tot += d[i],i--){
		for(int j = 0;j < d[i];j++)
			res = (res + s[i][j] + f[i][j] * tot%mod)%mod;
	}
	for(int i = 1;i <= cnt;i++) res = (res + d[i]) % mod;
	return res;
}			 
	
int main (){
	predo();
	int T; scanf("%d",&T);
	while(T--){
		ll l,r;scanf("%lld %lld",&l,&r);
		ll ans = (sum(r) - sum(l-1))%mod;
		printf("%lld\n",(ans+mod)%mod);
	}
	return 0;
}
